package respose

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

const (
	SUCCESS int = 1  //操作成功
	FAILED  int = -1 //操作失败
)

// Success 成功
func Success(c *gin.Context, data interface{}, message string) {
	c.JSON(http.StatusOK, gin.H{
		"code":    SUCCESS,
		"message": message,
		"data":    data,
	})
}

// Failed 失败
func Failed(c *gin.Context, message interface{}) {
	c.JSON(http.StatusOK, gin.H{
		"code":    FAILED,
		"message": message,
	})
	c.Abort()
}
